﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CMS.BLL;
using CMS.BLL.Entity;

public partial class AdminX_Cruise_CruiseAdd : System.Web.UI.UserControl
{
    private int nDefaultLanguage = Support.GetDefaultLanguage();
    protected void Page_Load(object sender, EventArgs e)
    {
        MessAlert1.HideMessage();
        if (!IsPostBack)
        {
            SetLable();
            SetValidate();
            BindDataPriorityDropdown();
            BindDataToLanguageDropdown();
            BindDataDurationToDropdownList();
            BindDataToCountryDropdown();
            InitData();
        }
    }
    private void SetValidate()
    {
        rfvTitle.ErrorMessage = MessagesValidate.TOUR_TITLE_EMPTY[nDefaultLanguage - 1];
        rfvInitContent.ErrorMessage = MessagesValidate.TOUR_INITCONTENT_EMPTY[nDefaultLanguage - 1];
        revPriceFrom.ErrorMessage = MessagesValidate.PRICEFROM_NUMBER[nDefaultLanguage - 1];
        revPriceTo.ErrorMessage = MessagesValidate.PRICEFROMTO_NUMBER[nDefaultLanguage - 1];
    }
    private void InitData()
    {
        string sQueery = ConvertData.ConvertToString(Request.QueryString[Config.ACTION]);

        try
        {
            if (sQueery == Config.ACTION_EDIT)
            {
                int nItemID = ConvertData.ConvertToInt(Request.QueryString[Config.ACTION_ID]);
                if (nItemID > 0)
                    GetData(nItemID);
            }
            else
            {
                imgImage.ImageUrl = Config.ROOT + "/Images/no_image.gif";
            }
        }
        catch
        {
            string sRedirect = Config.ROOT + Pages.BackEnds.ADMIN + "?" + Config.PAGE + "=" + Pages.BackEnds.STR_CRUISE + "&" + Config.MESS_ID + "=" + Config.ITEM_NOTEXIST;
            Response.Redirect(sRedirect);
        }
    }
    private void SetLable()
    {
        lblLanguage.Text = MultipleLanguage.LBL_LANGUAGE[nDefaultLanguage - 1];
        lblTitle.Text = MultipleLanguage.CRUISE_TITLE[nDefaultLanguage - 1];
        lblCountry.Text = MultipleLanguage.LBL_COUNTRY[nDefaultLanguage - 1];
        lblDuration.Text = MultipleLanguage.LBL_CRUISEDURATION[nDefaultLanguage - 1];
        lblImage.Text = MultipleLanguage.LBL_IMAGE[nDefaultLanguage - 1];
        lblImage1.Text = MultipleLanguage.LBL_IMAGE1[nDefaultLanguage - 1];
        lblImage2.Text = MultipleLanguage.LBL_IMAGE2[nDefaultLanguage - 1];
        lblImage3.Text = MultipleLanguage.LBL_IMAGE3[nDefaultLanguage - 1];
        lblImage4.Text = MultipleLanguage.LBL_IMAGE4[nDefaultLanguage - 1];
        lblImage5.Text = MultipleLanguage.LBL_IMAGE5[nDefaultLanguage - 1];
        lblInitContent.Text = MultipleLanguage.LBL_INIT_CONTENT[nDefaultLanguage - 1];
        lblLanguage.Text = MultipleLanguage.LBL_LANGUAGE[nDefaultLanguage - 1];
        lblPriceFrom.Text = MultipleLanguage.PRICEFROM[nDefaultLanguage - 1];
        lblPriceTo.Text = MultipleLanguage.PRICEFROMTO[nDefaultLanguage - 1];

        lblContent.Text = MultipleLanguage.CONTENT[nDefaultLanguage - 1];
        lblVideoLink.Text = MultipleLanguage.TOURVIDEO[nDefaultLanguage - 1];

        btnCancel.Text = MultipleLanguage.BTN_BACK[nDefaultLanguage - 1];
        btnSave.Text = MultipleLanguage.BTN_SAVE[nDefaultLanguage - 1];
        chkActive.Text = MultipleLanguage.STATUS_ACTIVE[nDefaultLanguage - 1];
        chkDisplayOrder.Text = MultipleLanguage.lbl_DesplayOrder[nDefaultLanguage - 1];

        rdoCruiseRegion1.Text = MultipleLanguage.HALONGCRUISE[nDefaultLanguage - 1];
        rdoCruiseRegion2.Text = MultipleLanguage.MEKONGCRUISE[nDefaultLanguage - 1];
        rdoType1.Text = MultipleLanguage.PRIVATE_CRUISETYPE[nDefaultLanguage-1];
        rdoType2.Text = MultipleLanguage.LUXURY_CRUISETYPE[nDefaultLanguage - 1];

        lblCruiseRegion.Text = MultipleLanguage.CRUISEREGION[nDefaultLanguage-1];
        lblContent_2day.Text = MultipleLanguage.CRUISECONTENT2DAY[nDefaultLanguage-1];
        lblContent_3day.Text = MultipleLanguage.CRUISECONTENT3DAY[nDefaultLanguage-1];
        lblType.Text = MultipleLanguage.CRUISETYPE[nDefaultLanguage - 1];
    }
    private void GetData(int ItemID)
    {
        int nStatus = 0;
        int nDisplayOrder = 0;
        int nCurrentLang = ConvertData.ConvertToInt(ddlLanguage.SelectedValue);

        Cruise objCruise = new Cruise();
        objCruise.LoadById(ItemID);

        txtPriceFrom.Text = ConvertData.ConvertToString(objCruise.Data.PriceFrom);
        txtPriceTo.Text = ConvertData.ConvertToString(objCruise.Data.PriceTo);
        ddlDuration.SelectedValue = ConvertData.ConvertToString(objCruise.Data.CruiseDurationID);
        ddlCountry.SelectedValue = ConvertData.ConvertToString(objCruise.Data.CountryID);

        switch (nCurrentLang)
        {
            case 1:

                txtTitle.Text = ConvertData.ConvertToString(objCruise.Data.Title1);
                txtInitContent.Text = ConvertData.ConvertToString(objCruise.Data.InitContent1);
                FTBContent.IntialText(ConvertData.ConvertToString(objCruise.Data.Content1));
                txtValContent_2day.IntialText(ConvertData.ConvertToString(objCruise.Data.Content1_2day));
                txtValContent_3day.IntialText(ConvertData.ConvertToString(objCruise.Data.Content1_3day));

                break;
            case 2:

                txtTitle.Text = ConvertData.ConvertToString(objCruise.Data.Title2);
                txtInitContent.Text = ConvertData.ConvertToString(objCruise.Data.InitContent2);
                FTBContent.IntialText(ConvertData.ConvertToString(objCruise.Data.Content2));
                txtValContent_2day.IntialText(ConvertData.ConvertToString(objCruise.Data.Content2_2day));
                txtValContent_3day.IntialText(ConvertData.ConvertToString(objCruise.Data.Content2_3day));
                break;
            case 3:
                txtTitle.Text = ConvertData.ConvertToString(objCruise.Data.Title3);
                txtInitContent.Text = ConvertData.ConvertToString(objCruise.Data.InitContent3);
                FTBContent.IntialText(ConvertData.ConvertToString(objCruise.Data.Content3));
                txtValContent_2day.IntialText(ConvertData.ConvertToString(objCruise.Data.Content3_2day));
                txtValContent_3day.IntialText(ConvertData.ConvertToString(objCruise.Data.Content3_3day));
                break;
        }

        if (objCruise.Data.Images != "")
            imgImage.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.Images.ToString();
        else imgImage.ImageUrl = Config.ROOT + "/Images/no_image.gif";

        if (objCruise.Data.ImageDetail1 != "")
            imgImage1.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail1.ToString();
        else imgImage1.ImageUrl = Config.ROOT + "/Images/no_image.gif";

        if (objCruise.Data.ImageDetail2 != "")
            imgImage2.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail2.ToString();
        else imgImage2.ImageUrl = Config.ROOT + "/Images/no_image.gif";

        if (objCruise.Data.ImageDetail3 != "")
            imgImage3.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail3.ToString();
        else imgImage3.ImageUrl = Config.ROOT + "/Images/no_image.gif";

        if (objCruise.Data.ImageDetail4 != "")
            imgImage4.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail4.ToString();
        else imgImage4.ImageUrl = Config.ROOT + "/Images/no_image.gif";

        if (objCruise.Data.ImageDetail5 != "")
            imgImage5.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail5.ToString();
        else imgImage5.ImageUrl = Config.ROOT + "/Images/no_image.gif";

        nDisplayOrder = ConvertData.ConvertToInt(objCruise.Data.Priority);
        if (nDisplayOrder > 0)
            chkDisplayOrder.Checked = true;
        else
            chkDisplayOrder.Checked = false;

        int nRegion = ConvertData.ConvertToInt(objCruise.Data.CruiseRegion);
        if (nRegion == 1)
        {
            rdoCruiseRegion1.Checked = true;
            rdoCruiseRegion2.Checked = false;
        }
        else
        {
            rdoCruiseRegion2.Checked = true;
            rdoCruiseRegion1.Checked = false;
        }

        int nType = ConvertData.ConvertToInt(objCruise.Data.Type);
        if (nType == 1)
        {
            rdoType1.Checked = true;
        }
        else
        {
            rdoType2.Checked = true;
        }

        nStatus = ConvertData.ConvertToInt(objCruise.Data.Status);
        if (nStatus > 0)
            chkActive.Checked = true;
        else
            chkActive.Checked = false;

        FTBVideoLink.IntialText(ConvertData.ConvertToString(objCruise.Data.VideoLink));
    }

    private void BindDataToCountryDropdown()
    {
        DataTable dtbCountry = new DataTable();
        Country objCountry = new Country();
        dtbCountry = objCountry.GetALL();

        ddlCountry.DataSource = dtbCountry;
        ddlCountry.DataValueField = "CountryID";
        switch (ConvertData.ConvertToInt(ddlLanguage.SelectedValue))
        {
            case 1:
                ddlCountry.DataTextField = "CountryName1";
                break;
            case 2:
                ddlCountry.DataTextField = "CountryName2";
                break;
            case 3:
                ddlCountry.DataTextField = "CountryName3";
                break;
        }
        ddlCountry.DataBind();
    }
    private void BindDataToLanguageDropdown()
    {
        DataTable dtbLanguage = new DataTable();
        Languages objLanguage = new Languages();
        dtbLanguage = objLanguage.Search();
        ddlLanguage.DataSource = dtbLanguage;
        ddlLanguage.DataValueField = "LanguageID";
        ddlLanguage.DataTextField = "Description";
        ddlLanguage.DataBind();

    }
    private eCruise CruiseEntity()
    {
        eCruise eCruise = new eCruise();
        int nItemID = ConvertData.ConvertToInt(Request.QueryString[Config.ACTION_ID]);
        string sQueery = ConvertData.ConvertToString(Request.QueryString[Config.ACTION]);
        if (nItemID > 0 && sQueery == Config.ACTION_EDIT)
        {
            Cruise objCruise = new Cruise();
            objCruise.LoadById(nItemID);
            eCruise = objCruise.Data;
        }
        return eCruise;
    }
    private eCruise setData()
    {
        eCruise eCruiseEntity = this.CruiseEntity();
        Cruise objCruise = new Cruise();
        int nCurrentLang = ConvertData.ConvertToInt(ddlLanguage.SelectedValue);

        objCruise.Data.PriceFrom = ConvertData.ConvertToInt(txtPriceFrom.Text.Trim());
        objCruise.Data.PriceTo = ConvertData.ConvertToInt(txtPriceTo.Text.Trim());
        objCruise.Data.CruiseDurationID = ConvertData.ConvertToInt(ddlDuration.SelectedValue);
        objCruise.Data.CountryID = ConvertData.ConvertToInt(ddlCountry.SelectedValue);

        switch (nCurrentLang)
        {
            case 1:
                objCruise.Data.Title2 = eCruiseEntity.Title2;
                objCruise.Data.InitContent2 = eCruiseEntity.InitContent2;
                objCruise.Data.Content2 = eCruiseEntity.Content2;
                objCruise.Data.Content2_2day = eCruiseEntity.Content2_2day;
                objCruise.Data.Content2_3day = eCruiseEntity.Content2_3day;

                objCruise.Data.Title3 = eCruiseEntity.Title3;
                objCruise.Data.InitContent3 = eCruiseEntity.InitContent3;
                objCruise.Data.Content3 = eCruiseEntity.Content3;
                objCruise.Data.Content3_2day = eCruiseEntity.Content3_2day;
                objCruise.Data.Content3_3day = eCruiseEntity.Content3_3day;

                objCruise.Data.Title1 = ConvertData.ConvertToString(ConvertData.RemoveHTMLTag(txtTitle.Text));
                objCruise.Data.InitContent1 = ConvertData.ConvertToString(ConvertData.RemoveHTMLTag(txtInitContent.Text));
                objCruise.Data.Content1 = ConvertData.ConvertToString(FTBContent.RenderText());
                objCruise.Data.Content1_2day = ConvertData.ConvertToString(txtValContent_2day.RenderText());
                objCruise.Data.Content1_3day = ConvertData.ConvertToString(txtValContent_3day.RenderText());
                break;
            case 2:

                objCruise.Data.Title1 = eCruiseEntity.Title1;
                objCruise.Data.InitContent1 = eCruiseEntity.InitContent1;
                objCruise.Data.Content1 = eCruiseEntity.Content1;
                objCruise.Data.Content1_2day = eCruiseEntity.Content1_2day;
                objCruise.Data.Content1_3day = eCruiseEntity.Content1_3day;

                objCruise.Data.Title3 = eCruiseEntity.Title3;
                objCruise.Data.InitContent3 = eCruiseEntity.InitContent3;
                objCruise.Data.Content3 = eCruiseEntity.Content3;
                objCruise.Data.Content3_2day = eCruiseEntity.Content3_2day;
                objCruise.Data.Content3_3day = eCruiseEntity.Content3_3day;

                objCruise.Data.Title2 = ConvertData.ConvertToString(ConvertData.RemoveHTMLTag(txtTitle.Text));
                objCruise.Data.InitContent2 = ConvertData.ConvertToString(ConvertData.RemoveHTMLTag(txtInitContent.Text));
                objCruise.Data.Content2 = ConvertData.ConvertToString(FTBContent.RenderText());
                objCruise.Data.Content2_2day = ConvertData.ConvertToString(txtValContent_2day.RenderText());
                objCruise.Data.Content2_3day = ConvertData.ConvertToString(txtValContent_3day.RenderText());
                break;
            case 3:
                objCruise.Data.Title1 = eCruiseEntity.Title1;
                objCruise.Data.InitContent1 = eCruiseEntity.InitContent1;
                objCruise.Data.Content1 = eCruiseEntity.Content1;
                objCruise.Data.Content1_2day = eCruiseEntity.Content1_2day;
                objCruise.Data.Content1_3day = eCruiseEntity.Content1_3day;

                objCruise.Data.Title2 = eCruiseEntity.Title2;
                objCruise.Data.InitContent2 = eCruiseEntity.InitContent2;
                objCruise.Data.Content2 = eCruiseEntity.Content2;
                objCruise.Data.Content2_2day = eCruiseEntity.Content2_2day;
                objCruise.Data.Content2_3day = eCruiseEntity.Content2_3day;

                objCruise.Data.Title3 = ConvertData.ConvertToString(ConvertData.RemoveHTMLTag(txtTitle.Text));
                objCruise.Data.InitContent3 = ConvertData.ConvertToString(ConvertData.RemoveHTMLTag(txtInitContent.Text));
                objCruise.Data.Content3 = ConvertData.ConvertToString(FTBContent.RenderText());
                objCruise.Data.Content3_2day = ConvertData.ConvertToString(txtValContent_2day.RenderText());
                objCruise.Data.Content3_3day = ConvertData.ConvertToString(txtValContent_3day.RenderText());
                break;
        }

 
        if (iptImage.Value != "")
        {
            Support.DeleteFile("Cruise", eCruiseEntity.Images);
            objCruise.Data.Images = Support.UploadFile(iptImage, "Cruise");
        }
        else
        { 
            if (eCruiseEntity.Images != "")
              objCruise.Data.Images = ConvertData.ConvertToString(eCruiseEntity.Images);
            else objCruise.Data.Images = "";
        } 

        if (iptImage1.Value != "")
        {
            Support.DeleteFile("Cruise", eCruiseEntity.ImageDetail1);
            objCruise.Data.ImageDetail1 = Support.UploadFile(iptImage1, "Cruise");
        }
        else
        {
            if (eCruiseEntity.ImageDetail1 != "")
                objCruise.Data.ImageDetail1 = ConvertData.ConvertToString(eCruiseEntity.ImageDetail1);
            else objCruise.Data.ImageDetail1 = "";
        }

        if (iptImage2.Value != "")
        {
            Support.DeleteFile("Cruise", eCruiseEntity.ImageDetail2);
            objCruise.Data.ImageDetail2 = Support.UploadFile(iptImage2, "Cruise");
        }
        else
        {
            if (eCruiseEntity.ImageDetail2 != "")
                objCruise.Data.ImageDetail2 = ConvertData.ConvertToString(eCruiseEntity.ImageDetail2);
            else objCruise.Data.ImageDetail2 = "";
        }

        if (iptImage3.Value != "")
        {
            Support.DeleteFile("Cruise", eCruiseEntity.ImageDetail3);
            objCruise.Data.ImageDetail3 = Support.UploadFile(iptImage3, "Cruise");
        }
        else
        {
            if (eCruiseEntity.ImageDetail3 != "")
                objCruise.Data.ImageDetail3 = ConvertData.ConvertToString(eCruiseEntity.ImageDetail3);
            else objCruise.Data.ImageDetail3 = "";
        }

        if (iptImage4.Value != "")
        {
            Support.DeleteFile("Cruise", eCruiseEntity.ImageDetail4);
            objCruise.Data.ImageDetail4 = Support.UploadFile(iptImage4, "Cruise");
        }
        else
        {
            if (eCruiseEntity.ImageDetail4 != "")
                objCruise.Data.ImageDetail4 = ConvertData.ConvertToString(eCruiseEntity.ImageDetail4);
            else objCruise.Data.ImageDetail4 = "";
        }

        if (iptImage5.Value != "")
        {
            Support.DeleteFile("Cruise", eCruiseEntity.ImageDetail5);
            objCruise.Data.ImageDetail5 = Support.UploadFile(iptImage5, "Cruise");
        }
        else
        {
            if (eCruiseEntity.ImageDetail5 != "")
                objCruise.Data.ImageDetail5 = ConvertData.ConvertToString(eCruiseEntity.ImageDetail5);
            else objCruise.Data.ImageDetail5 = "";
        }

        if (chkDisplayOrder.Checked) objCruise.Data.Priority = ConvertData.ConvertToInt(ddlPriority.SelectedValue);
        else objCruise.Data.Priority = 0;

        if (chkActive.Checked) objCruise.Data.Status = Config.STATUS_ACTIVE;
        else objCruise.Data.Status = Config.STATUS_INACTIVE;
        
        string sMainContent = ConvertData.ConvertToString(FTBVideoLink.RenderText());
        objCruise.Data.VideoLink = sMainContent;

        if (objCruise.Data.CountryID == 1)
        {
            if (rdoCruiseRegion1.Checked)
            {
                objCruise.Data.CruiseRegion = 1;
            }
            else
            {
                objCruise.Data.CruiseRegion = 2;
            }
        }
        else
        {
            objCruise.Data.CruiseRegion = 0;
        }
        

        if (rdoType1.Checked)
        {
            objCruise.Data.Type = 1;
        }
        else
        {
            objCruise.Data.Type = 2;
        }
        return objCruise.Data;
    }
    private void BindDataDurationToDropdownList()
    {
        TourDuration obj = new TourDuration();
        DataTable dtb = new DataTable();

        dtb = obj.GetALL();
        ddlDuration.DataSource = dtb;
        int nCurrentLang = ConvertData.ConvertToInt(ddlLanguage.SelectedValue);
        switch (nCurrentLang)
        {
            case 1:
                ddlDuration.DataTextField = "DurationDescription1";
                break;
            case 2:
                ddlDuration.DataTextField = "DurationDescription2";
                break;
            case 3:
                ddlDuration.DataTextField = "DurationDescription3";
                break;
        }
        ddlDuration.DataValueField = "DurationID";
        ddlDuration.DataBind();

    }
    private void BindDataPriorityDropdown()
    {
        DataTable dtbCruise = new DataTable();
        Cruise objCruise = new Cruise();

        dtbCruise = objCruise.GetALL();
        int nCount = dtbCruise.Rows.Count;
        string sAction = GetQuerryString(Config.ACTION);//Lay Thong tin Edit, Insert
        int nRealValue = 0;
        if (sAction == Config.ACTION_EDIT)//Kiem tra dieu kien
        {
            eCruise eCruiseEntity = this.CruiseEntity();
            if (ConvertData.ConvertToInt(eCruiseEntity.Priority) < nCount)
            {
                nRealValue = nCount;
            }
            else
            {
                nRealValue = ConvertData.ConvertToInt(eCruiseEntity.Priority);
            }
            for (int i = 0; i < nRealValue; i++)
            {
                ddlPriority.Items.Add(ConvertData.ConvertToString(i + 1));
            }

            string sPriority = ConvertData.ConvertToString(eCruiseEntity.Priority);
            ddlPriority.SelectedValue = sPriority;
        }
        else
        {
            nRealValue = nCount + 1;
            for (int i = 0; i < nRealValue; i++)
            {
                ddlPriority.Items.Add(ConvertData.ConvertToString(i + 1));
            }
            ddlPriority.SelectedValue = ConvertData.ConvertToString(nRealValue);
        }
    }
    
    protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindDataDurationToDropdownList();
        BindDataToCountryDropdown();
        InitData();
    }
    
    protected void btnCancel_Click(object sender, EventArgs e)
    {

    }
    private string GetQuerryString(string sQuerry)
    {
        string sQuerryString = "";
        sQuerryString = ConvertData.ConvertToString(Request.QueryString[sQuerry]);
        return sQuerryString;
    }
    protected void btnSave_Click1(object sender, EventArgs e)
    {
        
        int nActionResult = 0;
        int nDefaultLanguage = Support.GetDefaultLanguage();
        
            Cruise objCruise = new Cruise();
            objCruise.Data = this.setData();
            string sAction = GetQuerryString(Config.ACTION);
            if (sAction == Config.ACTION_EDIT)
            {
                int nItemID = ConvertData.ConvertToInt(Request.QueryString[Config.ACTION_ID]);
                nActionResult = objCruise.Update(nItemID);//Update
               
                if (nActionResult > 0)//Kiem tra co loi xay ra
                {
                    
                    MessAlert1.ShowMessage(1, MessagesAlert.UPDATE_SUCCESSFUL[nDefaultLanguage - 1]);
                    if (objCruise.Data.Images.ToString() != "")
                    {
                        imgImage.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.Images.ToString();
                    }
                    if (objCruise.Data.Images.ToString() == "")
                    {
                        objCruise.Data.Images = Config.ROOT + "/Images/no_image.gif";
                    }

                    if (objCruise.Data.ImageDetail1.ToString() != "")
                    {
                        imgImage1.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail1.ToString();
                    }
                    if (objCruise.Data.ImageDetail1.ToString() == "")
                    {
                        objCruise.Data.ImageDetail1 = Config.ROOT + "/Images/no_image.gif";
                    }

                    if (objCruise.Data.ImageDetail5.ToString() != "")
                    {
                        imgImage2.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail5.ToString();
                    }
                    if (objCruise.Data.ImageDetail5.ToString() == "")
                    {
                        objCruise.Data.ImageDetail5 = Config.ROOT + "/Images/no_image.gif";
                    }

                    if (objCruise.Data.ImageDetail3.ToString() != "")
                    {
                        imgImage3.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail3.ToString();
                    }
                    if (objCruise.Data.ImageDetail3.ToString() == "")
                    {
                        objCruise.Data.ImageDetail3 = Config.ROOT + "/Images/no_image.gif";
                    }

                    if (objCruise.Data.ImageDetail4.ToString() != "")
                    {
                        imgImage4.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail4.ToString();
                    }
                    if (objCruise.Data.ImageDetail4.ToString() == "")
                    {
                        objCruise.Data.ImageDetail4 = Config.ROOT + "/Images/no_image.gif";
                    }

                    if (objCruise.Data.ImageDetail5.ToString() != "")
                    {
                        imgImage5.ImageUrl = Config.ROOT + Config.IMAGE_CRUISE_DEFAULT_UPLOAD + objCruise.Data.ImageDetail5.ToString();
                    }
                    if (objCruise.Data.ImageDetail5.ToString() == "")
                    {
                        objCruise.Data.ImageDetail5 = Config.ROOT + "/Images/no_image.gif";
                    }
                }
                else
                    MessAlert1.ShowMessage(2, MessagesAlert.UPDATE_UNSUCCESSFUL[nDefaultLanguage - 1]);
            }
            else
            {
                nActionResult = objCruise.Insert();
                if (nActionResult > 0)
                {
                    string sURL = Config.ROOT + Pages.BackEnds.ADMIN + "?" + Config.PAGE + "=" + Pages.BackEnds.STR_CRUISE + "&" + Config.MESS_ID + "=" + Config.MESSAGE_INSERT;
                    Response.Redirect(sURL);
                }
            }
    }
}